/*
 * @ProjectName: 编程学习
 * @Copyright:   2019 HangZhou Yi Dev, Ltd. All Right Reserved.
 * @address:     https://yiyuery.github.io/
 * @date:        2019/5/20 20:57
 * @email:       xiazhaoyang@live.com
 * @description: 本内容仅限于编程技术学习使用，转发请注明出处.
 */
package com.example.springfox.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.annotations.ApiIgnore;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * <p>
 *
 * </p>
 *
 * @author Yi
 * @version v1.0.0
 * @date 2019-06-07 04:44
 * @modificationHistory=========================逻辑或功能性重大变更记录
 * @modify By: {修改人} 2019-06-07
 * @modify reason: {方法名}:{原因}
 * ...
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    /**
     * UI接口
     *
     * @return springfox.documentation.spring.web.plugins.Docket
     * @author Ashe
     * @date 2018/04/16 11:20
     * @modify by user: {修改人}  2018/1/29 11:20
     * @modify by reason:
     */
    @Bean
    public Docket uiDocket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(uiRestInfo())
                .groupName("UI")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.example.springfox.controller"))
                .paths(PathSelectors.ant("/user/**"))
                .build()
                //.pathMapping("/swagger-resources")
                .host("localhost:9000")
                .ignoredParameterTypes(ApiIgnore.class);
    }

    private ApiInfo uiRestInfo() {
        return new ApiInfoBuilder()
                .version("V1.0.0")
                .title("前端接口说明书V1.0.0")
                .description("前端UI接口")
                .contact(new Contact("xxx", "", "xx@xx.com"))
                .license("license 地址（可为空）")
                .licenseUrl("http://xxxx/index.html")
                .build();
    }
}
